/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FrmGetPlayers.java
 *
 * Created on 17/04/2010, 13:03:48
 */
package game_interface;

import game_logic.Color;
import game_logic.Player;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Danilo
 */
public class DlgGetPlayers extends javax.swing.JDialog {

    /** Creates new form FrmGetPlayers */
    private List<Player> players;

    public DlgGetPlayers(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }

    public List<Player> getPlayers(){
        return players;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btgVerde = new javax.swing.ButtonGroup();
        btgVermelho = new javax.swing.ButtonGroup();
        btgAzul = new javax.swing.ButtonGroup();
        btgAmarelo = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        rbVerdeHumano = new javax.swing.JRadioButton();
        rbVerdeCPU = new javax.swing.JRadioButton();
        rbVerdDesab = new javax.swing.JRadioButton();
        jLabel2 = new javax.swing.JLabel();
        rbVermelhoHumano = new javax.swing.JRadioButton();
        rbVermelhoCPU = new javax.swing.JRadioButton();
        rbVermelhoDesab = new javax.swing.JRadioButton();
        jLabel3 = new javax.swing.JLabel();
        rbAzulHumano = new javax.swing.JRadioButton();
        rbAzulCPU = new javax.swing.JRadioButton();
        rbAzulDesab = new javax.swing.JRadioButton();
        jLabel4 = new javax.swing.JLabel();
        rbAmareloHumano = new javax.swing.JRadioButton();
        rbAmareloCPU = new javax.swing.JRadioButton();
        rbAmareloDesab = new javax.swing.JRadioButton();
        jToggleButton1 = new javax.swing.JToggleButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel1.setForeground(new java.awt.Color(0, 153, 0));
        jLabel1.setText("Jogador Verde - ");

        btgVerde.add(rbVerdeHumano);
        rbVerdeHumano.setSelected(true);
        rbVerdeHumano.setText("Humano");

        btgVerde.add(rbVerdeCPU);
        rbVerdeCPU.setText("CPU");

        btgVerde.add(rbVerdDesab);
        rbVerdDesab.setText("Desabilitado");

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel2.setForeground(new java.awt.Color(255, 0, 0));
        jLabel2.setText("Jogador Vermelho -");

        btgVermelho.add(rbVermelhoHumano);
        rbVermelhoHumano.setSelected(true);
        rbVermelhoHumano.setText("Humano");

        btgVermelho.add(rbVermelhoCPU);
        rbVermelhoCPU.setText("CPU");

        btgVermelho.add(rbVermelhoDesab);
        rbVermelhoDesab.setText("Desabilitado");

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel3.setForeground(new java.awt.Color(0, 0, 255));
        jLabel3.setText("Jogador Azul -");

        btgAzul.add(rbAzulHumano);
        rbAzulHumano.setSelected(true);
        rbAzulHumano.setText("Humano");

        btgAzul.add(rbAzulCPU);
        rbAzulCPU.setText("CPU");

        btgAzul.add(rbAzulDesab);
        rbAzulDesab.setText("Desabilitado");

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel4.setForeground(new java.awt.Color(255, 255, 0));
        jLabel4.setText("Jogador Amarelo -");

        btgAmarelo.add(rbAmareloHumano);
        rbAmareloHumano.setSelected(true);
        rbAmareloHumano.setText("Humano");

        btgAmarelo.add(rbAmareloCPU);
        rbAmareloCPU.setText("CPU");

        btgAmarelo.add(rbAmareloDesab);
        rbAmareloDesab.setText("Desabilitado");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 128, Short.MAX_VALUE))
                .addGap(6, 6, 6)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(rbVerdeHumano)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(rbVerdeCPU))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(rbVermelhoHumano)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(rbVermelhoCPU))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(rbAzulHumano)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(rbAzulCPU)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(rbAzulDesab, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(rbVermelhoDesab)
                            .addComponent(rbVerdDesab)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(rbAmareloHumano)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(rbAmareloCPU)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(rbAmareloDesab)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(rbVerdeHumano)
                    .addComponent(rbVerdeCPU)
                    .addComponent(rbVerdDesab))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(rbVermelhoHumano)
                    .addComponent(rbVermelhoCPU)
                    .addComponent(rbVermelhoDesab))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(rbAzulDesab)
                    .addComponent(rbAzulHumano)
                    .addComponent(rbAzulCPU))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(rbAmareloHumano)
                    .addComponent(rbAmareloCPU)
                    .addComponent(rbAmareloDesab))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jToggleButton1.setText("OK!");
        jToggleButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jToggleButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jToggleButton1)
                        .addGap(145, 145, 145))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(11, 11, 11)
                .addComponent(jToggleButton1)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jToggleButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButton1ActionPerformed


        Player p1 = null;

        if( rbAzulHumano.isSelected() ){
            p1 = new HumanPlayer(Color.BLUE,"");
        }else if( rbAzulCPU.isSelected() ){
            p1 = new CPUPlayer(Color.BLUE, "");
        }

        Player p2 = null;

        if( rbVermelhoHumano.isSelected() ){
            p2 = new HumanPlayer(Color.GREEN,"");
        }else if( rbVermelhoCPU.isSelected() ){
            p2 = new CPUPlayer(Color.GREEN, "");
        }

        Player p3 = null;

        if( rbAzulHumano.isSelected() ){
            p3 = new HumanPlayer(Color.BLUE,"");
        }else if( rbAzulCPU.isSelected() ){
            p3 = new CPUPlayer(Color.BLUE, "");
        }

        Player p4 = null;

        if( rbAmareloHumano.isSelected() ){
            p4 = new HumanPlayer(Color.BLUE,"");
        }else if( rbAmareloCPU.isSelected() ){
            p4 = new CPUPlayer(Color.BLUE, "");
        }

        players = new ArrayList<Player>();
        players.add(p1);
        players.add(p2);
        players.add(p3);
        players.add(p4);

    }//GEN-LAST:event_jToggleButton1ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                DlgGetPlayers dialog = new DlgGetPlayers(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup btgAmarelo;
    private javax.swing.ButtonGroup btgAzul;
    private javax.swing.ButtonGroup btgVerde;
    private javax.swing.ButtonGroup btgVermelho;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JToggleButton jToggleButton1;
    private javax.swing.JRadioButton rbAmareloCPU;
    private javax.swing.JRadioButton rbAmareloDesab;
    private javax.swing.JRadioButton rbAmareloHumano;
    private javax.swing.JRadioButton rbAzulCPU;
    private javax.swing.JRadioButton rbAzulDesab;
    private javax.swing.JRadioButton rbAzulHumano;
    private javax.swing.JRadioButton rbVerdDesab;
    private javax.swing.JRadioButton rbVerdeCPU;
    private javax.swing.JRadioButton rbVerdeHumano;
    private javax.swing.JRadioButton rbVermelhoCPU;
    private javax.swing.JRadioButton rbVermelhoDesab;
    private javax.swing.JRadioButton rbVermelhoHumano;
    // End of variables declaration//GEN-END:variables
}
